# 获取驱动对象
from selenium import webdriver
from selenium.webdriver.chrome.service import Service


class DriverUtils:
    # 私有的人力资源管理驱动对象
    __admin_driver = None
    __admin_key = None
    # 修改关闭驱动对象开关值的方法
    @classmethod
    def change_admin_key(cls, key):
        cls.__admin_key = key

    # 获取游览器驱动对象
    @classmethod
    def get_driver(cls):
       if cls.__admin_driver is None:
           service = Service('D:/ChromeDriver/chromedriver.exe')
           cls.__admin_driver = webdriver.Chrome(service=service)
           # 最大化窗口
           cls.__admin_driver.maximize_window()

       return cls.__admin_driver


    @classmethod
    def close_driver(cls):
        if cls.__admin_driver is not  None and cls.__admin_key :
            cls.__admin_driver.quit()
            # 置空
            cls.__admin_driver = None
